# Maintainer: Andrzej Giniewicz <gginiu@gmail.com>
# Maintainer: George Rawlinson <grawlinson@archlinux.org>

pkgname=blosc
pkgver=1.21.5
pkgrel=1
pkgdesc='A blocking, shuffling and loss-less compression library'
arch=('loong64' 'x86_64')
url='https://www.blosc.org'
license=('BSD')
depends=(
  'glibc'
  'lz4'
  'snappy'
  'zlib'
  'zstd'
)
makedepends=('cmake')
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/Blosc/c-blosc/archive/v${pkgver}.tar.gz")
sha512sums=('01e6d80e1114d76c4bd1b413778c293d0455879ec38e1e1ec46e8e7eaf2997b47cc2de35bc52cdc4c2c70341b6f87d70626a9a9c24ffc8b7b170d760efa60c07')
b2sums=('f56e19146a1522554d5e8de23f580125a6181b50f1898c8e622e8ac50f2f40ab4cdaba62a5a2bc6ff437257550e205090ebe66bb8840202a26567abfc63fbf53')

build() {
  cmake \
    -B build \
    -S "c-blosc-$pkgver" \
    -D CMAKE_INSTALL_PREFIX="/usr" \
    -D BUILD_STATIC="OFF" \
    -D DEACTIVATE_SNAPPY="OFF" \
    -D PREFER_EXTERNAL_LZ4="ON" \
    -D PREFER_EXTERNAL_ZLIB="ON" \
    -D PREFER_EXTERNAL_ZSTD="ON"

  cmake --build build
}

check() {
  cd build

  ctest --output-on-failure
}

package() {
  DESTDIR="$pkgdir" cmake --install build

  install -vDm644 \
    "c-blosc-$pkgver/LICENSE.txt" \
    "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
